import ToolActionApi from "@/tool/http/tool-action.js";

let deviceAction = ToolActionApi.init("things_device");

const rule = {
  queryParams: [],
  extendField: "config",
  metadata: [{ name: "code", memo: "设备信息" }],
  extendFields: [
    {
      name: "open",
      block: "ai-vision",
      blockMemo: "AI配置",
      memo: "是否开启",
      dictList: [
        { name: "开启", val: "true" },
        { name: "关闭", val: "false" },
      ],
    },
    {
      name: "open_models",
      block: "ai-vision",
      blockMemo: "AI配置",
      multiple: true,
      memo: "分析模型配置",
      dictListFun: () => {
        return ToolActionApi.enumDict("AI_mode_type");
      },
    },
    {
      name: "emergency_valve",
      block: "isd",
      blockMemo: "智能排污",
      memo: "应急阀",
      dictList: [
        { name: "存在", val: "true" },
        { name: "不存在", val: "false" },
      ],
    },
  ],
};

export default async function () {
  rule.metadata[0].dictList = await deviceAction.dict("name", "code");
  return rule;
}
